package com.deepfos.outreach.util;

import cn.hutool.core.io.IoUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.http.server.ServerHttpRequest;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.StringWriter;

/**
 */
public class ServletUtil {
	private ServletUtil() {}
	
	public static JSONObject getRequestJson(HttpServletRequest request) throws IOException {
		StringWriter sw = new StringWriter();
		IoUtil.copy(request.getReader(), sw);
		sw.flush();
		String requestJson = sw.toString();
		JSONObject parseObj = JSONObject.parseObject(requestJson);
		return parseObj;
	}

}
